package com.mier.android.fbtalksms;

import java.io.InputStream;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;


public class FriendsListLoader extends AsyncTask<Object, Void, Bitmap>{
	
	private View view;
	private ImageView imgView;
	

	@Override
	protected Bitmap doInBackground(Object... params) {
		// TODO Auto-generated method stub
		Bitmap bitmap;
		imgView = (ImageView) params[0];
		bitmap = getUserPic((String)imgView.getTag());
		return bitmap;
	}
	
	@Override
	protected void onPostExecute(Bitmap bitmap){
		Log.d("com.mier.android.FBFriendsList", "Setting the image to the image view.");
		
	    imgView.setImageBitmap(bitmap);
	}
	
	public static Bitmap getUserPic(String url) {
		String imageURL= url;
		Bitmap bitmap = null;
		Log.d("com.mier.android.FBFriendsList", imageURL);
		Log.d("com.mier.android.FBFriendsList", "Loading Picture");
		try {
			bitmap = BitmapFactory.decodeStream((InputStream) new URL(imageURL)
					.getContent());
		} catch (Exception e) {
			Log.d("TAG", "Loading Picture FAILED");
			e.printStackTrace();
		}
		return bitmap;
	}


	
	
	

}
